package com.ruihu.admin.common.constant;

import com.ruihu.admin.common.domain.BaseEnum;

import java.util.Arrays;
import java.util.Optional;

/**
 * 系统环境
 */
public enum SystemEnvEnum implements BaseEnum {

    DEV_ENV(Byte.valueOf("0"), "Develop Environment"),

    SIT_ENV(Byte.valueOf("1"), "Sit Environment"),

    PROD_ENV(Byte.valueOf("2"), "Production Environment");

    private byte env = 0;

    private String desc;

    SystemEnvEnum(byte env, String desc) {
        this.env = env;
        this.desc = desc;
    }

    @Override
    public Byte getValue() {
        return this.env;
    }

    @Override
    public String getDesc() {
        return this.desc;
    }

    public static SystemEnvEnum valueOf(byte val) {
        SystemEnvEnum[] values = SystemEnvEnum.values();
        Optional<SystemEnvEnum> first = Arrays.stream(values).filter(e -> e.getValue().equals(val)).findFirst();
        return !first.isPresent() ? null : first.get();
    }
}
